import {getDriverTask} from "@/api/task"
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    activeIndex: '2',
    items:{
    },
    status:0
  },

  onSearch(){

  },

  onCancel(){
    
  },
  handleClick(event) {
    // console.log(event)
    const index = event.currentTarget.dataset.index; // 获取当前点击字段的索引
    this.setData({
      activeIndex: index // 更新 activeIndex
    });
    console.log(this.data.activeIndex)
    switch(this.data.activeIndex){
      case '2':
        this.getDriverTask(0)
      case '1':
        this.getDriverTask(1)
      case '3':
        this.getDriverTask(3)
      default:
        this.getDriverTask(4)
    }
  },

  onShow(){
    this.getDriverTask(0)
  },

  async getDriverTask(status){
    const { driverId = '' } =  app.globalData.userInfo || {}
    const data = await getDriverTask(driverId,status)
    this.setData({
      items: data
    })
  }
})